﻿<phoneNavigation:PhoneApplicationPage 
    x:Class="wpProtractor.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:wpProtractor" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}">

    <UserControl.Resources>
        <local:DoubleConverter x:Key="doubleConverter" />
        <local:HalfConverter x:Key="halfConverter" />
        <local:NegativeDoubleConverter x:Key="negativeDoubleConverter" />
    </UserControl.Resources>

    <Canvas x:Name="LayoutRoot" Background="white">    
        <Canvas>
            <!-- app width and height / 2 -->
            <Line
				X1="0" 
				X2="{Binding Path=ActualWidthBind, Converter={StaticResource doubleConverter}}"
				Y1="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource halfConverter}}"
				Y2="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource halfConverter}}"
	  			Stroke="Black"
	  			StrokeThickness="4" StrokeDashArray="4 4"
	  			x:Name="foo" />
            <!-- app width / 2 and height -->
            <Line
				X1="{Binding Path=ActualWidthBind, Mode=OneWay, Converter={StaticResource halfConverter}}" 
				X2="{Binding Path=ActualWidthBind, Mode=OneWay, Converter={StaticResource halfConverter}}" 
				Y1="0" 
				Y2="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource doubleConverter}}"
	  			Stroke="Black"
	  			StrokeThickness="4" StrokeDashArray="4 4" />
        </Canvas>
        <Canvas Name="rotateGrid">
            <Canvas.RenderTransform>
                <TransformGroup>
                    <RotateTransform />
                </TransformGroup>
            </Canvas.RenderTransform>
            <!-- app width and height / 2 -->
            <TextBlock x:Name="currAngle" TextAlignment="Right" 
				Canvas.Top="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource halfConverter}}" 
				Canvas.Left="{Binding Path=ActualWidthBind, Mode=OneWay, Converter={StaticResource halfConverter}}" Foreground="Black" />
            <Line
				X1="{Binding Path=ActualWidthBind, Mode=OneWay, Converter={StaticResource negativeDoubleConverter}}" 
				X2="{Binding Path=ActualWidthBind, Mode=OneWay, Converter={StaticResource doubleConverter}}"
				Y1="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource halfConverter}}"
				Y2="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource halfConverter}}"
	  			Stroke="Black"
	  			StrokeThickness="1" />
            <Line 
				X1="{Binding Path=ActualWidthBind, Mode=OneWay, Converter={StaticResource halfConverter}}" 
				X2="{Binding Path=ActualWidthBind, Mode=OneWay, Converter={StaticResource halfConverter}}" 
				Y1="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource negativeDoubleConverter}}" 
				Y2="{Binding Path=ActualHeightBind, Mode=OneWay, Converter={StaticResource doubleConverter}}"
	  			Stroke="Black"
	  			StrokeThickness="1" />
        </Canvas>
        <Canvas Name="angleCanvas">
            <Canvas.RenderTransform>
                <TransformGroup>
                    <!-- app height / 2 and width / 2 -->
                    <TranslateTransform />
                </TransformGroup>
            </Canvas.RenderTransform>
            <!-- math here would be figure out ArcSegment Point based on angle and length of first line Segment -->
            <Path Stroke="#FF00FE00" StrokeThickness="4" StrokeLineJoin="Round" StrokeEndLineCap="Round" StrokeStartLineCap="Round" >
                <Path.Data>
                    <PathGeometry>
                        <PathFigure StartPoint="0,0">
                            <LineSegment x:Name="primaryAngleAdjacent" />
                            <ArcSegment RotationAngle="0" IsLargeArc="False" 
								SweepDirection="Clockwise" x:Name="primaryAngleHypotenuse" />
                            <LineSegment Point="0,0" />
                        </PathFigure>
                    </PathGeometry>
                </Path.Data>
            </Path>
        </Canvas>
        <StackPanel HorizontalAlignment="Right" VerticalAlignment="Top">
            <TextBlock Foreground="Black">Pitch:</TextBlock>
            <TextBlock Name="Pitch" Foreground="Black" />
            
            <TextBlock Foreground="Black">Roll: </TextBlock>
            <TextBlock Name="Roll" Foreground="Black" />
            
        </StackPanel>
        
                   
    </Canvas>
</phoneNavigation:PhoneApplicationPage>